﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PasswordProvider.ObjectModel;
using PasswordProvider.ViewModel.Service;
using PasswordProvider.ViewModel.Properties;

namespace PasswordProvider.ViewModel
{
    sealed class GenericSiteListItemViewModel : SiteListItemViewModel
    {
        internal GenericSiteListItemViewModel(GenericSite site)
            : base(site)
        {
            
        }

        public override string GroupDisplayName
        {
            get { return Strings.ListItem_Generic_DisplayName; }
        }

        protected override INotifyChangesCommited GoToSiteDetails()
        {
            return (INotifyChangesCommited)NavigationManager.GoToSiteDetailsView(Site as GenericSite, false);
        }

        protected override string GenerateToolTip()
        {
            return Site.Name + "/n" + Site.Description;
        }

        protected override string GenerateDisplayName()
        {
            return Site.Name;
        }

        protected override bool NavigateToWebSiteCommandCanExecute()
        {
            GenericSite site = (GenericSite)Site;
            return (site.Website != null && site.Website.Url != null);
        }

        protected override void NavigateToWebSiteCommandExecuted()
        {
            GenericSite site = (GenericSite)Site;
            if(site.Website != null && site.Website.Url != null)
                base.NavigateToWebSite(site.Website);
        }
    }
}
